﻿using MediatR;
using Traceability.Commont.Domains.BatchManagementFiles;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;
namespace U.Enterprise.Api.Applications.ReturnWeighing
{
    public class ReturnWeighingCreateHandlercs : IRequestHandler<ReturnWeighingCreateCommond, Resqults>
    {

        private readonly IBateRepository<Byproduct> _Byproduct;

        public ReturnWeighingCreateHandlercs(IBateRepository<Byproduct> byproduct)
        {
            _Byproduct = byproduct;
        }

        public async Task<Resqults> Handle(ReturnWeighingCreateCommond request, CancellationToken cancellationToken)
        {


            var result= new Resqults() { Code=0 };

            var list=_Byproduct.GetAll();

            var res = new Byproduct()
            {
                ShoppingName=request.ShoppingName,
                ShoppingType=request.ShoppingType,
                Stashid=0,
                ByproductDate=request.ByproductDate,
                ByproductId=request.ByproductId,
                byproductNetWeight =request.byproductNetWeight,
                byproductNoteTare=request.byproductNoteTare,
                byproductNoteWeight=request.byproductNoteWeight,
                byproductNum=request.byproductNum,
                DocumentsNo=request.DocumentsNo,
                Rremark=request.Rremark

            };

            var query=await _Byproduct.Add(res);
            if(query!=null)
            {


                result.Code = 1;

            }



            return result;
           
        }
    }
}
